stylecontext: Compute correct changes
authorBenjamin Otte <otte@redhat.com>
Fri, 24 Aug 2012 14:28:47 +0000 (16:28 +0200)
committerBenjamin Otte <otte@redhat.com>
Tue, 28 Aug 2012 13:42:24 +0000 (15:42 +0200)
... in the case where no change of the DOM tree actually happened.

We don't do anything yet with that information, this patch just
correctly computes it.

gtk/gtkstylecontext.c

index 281be0f8f9e98abd3272937d3b443f668b69dc1d..a98f194cb9ce65e77e12709887c7456f027ff1a2 100644 (file)
@@ -3071,6 +3071,8 @@ _gtk_style_context_validate (GtkStyleContext  *context,
                              const GtkBitmask *parent_changes)
 {
   GtkStyleContextPrivate *priv;
+  GtkStyleInfo *info;
+  StyleData *current;
   GtkBitmask *changes;
   GSList *list;
 
@@ -3095,23 +3097,22 @@ _gtk_style_context_validate (GtkStyleContext  *context,
   if (G_UNLIKELY (gtk_get_debug_flags () & GTK_DEBUG_NO_CSS_CACHE))
     change = GTK_CSS_CHANGE_ANY;
 
-  if (!priv->invalid && change == 0)
+  if (!priv->invalid && change == 0 && _gtk_bitmask_is_empty (parent_changes))
     return;
 
   priv->pending_changes = 0;
   gtk_style_context_set_invalid (context, FALSE);
 
+  info = priv->info;
+  if (info->data)
+    current = style_data_ref (info->data);
+  else
+    current = NULL;
+
   /* Try to avoid invalidating if we can */
-  if (gtk_style_context_needs_full_revalidate (context, change))
+  if (current == NULL ||
+      gtk_style_context_needs_full_revalidate (context, change))
     {
-      GtkStyleInfo *info = priv->info;
-      StyleData *current;
-
-      if (info->data)
-        current = style_data_ref (info->data);
-      else
-        current = NULL;
-
       if ((priv->relevant_changes & change) & ~GTK_STYLE_CONTEXT_CACHED_CHANGE)
         gtk_style_context_clear_cache (context);
       else
@@ -3137,7 +3138,14 @@ _gtk_style_context_validate (GtkStyleContext  *context,
         }
     }
   else
-    changes = _gtk_bitmask_new ();
+    {
+      changes = _gtk_bitmask_copy (parent_changes);
+      changes = _gtk_bitmask_intersect (changes, current->store->depends_on_parent);
+      if (_gtk_bitmask_get (changes, GTK_CSS_PROPERTY_COLOR))
+        changes = _gtk_bitmask_union (changes, current->store->depends_on_color);
+      if (_gtk_bitmask_get (changes, GTK_CSS_PROPERTY_FONT_SIZE))
+        changes = _gtk_bitmask_union (changes, current->store->depends_on_font_size);
+    }
 
   if (change & GTK_CSS_CHANGE_ANIMATE &&
       gtk_style_context_is_animating (context))